package com.foreknow.demo2;

/**
 * int[] array = new int[10];
 */
public class ArrayDemo1 {
    public static void main(String[] args) {
        //创建一个整型数组,下标从0到4,该数组中可以存5个元素
        int[] array = new int[5];
        //向array数组容器中添加一个元素
        array[0] = 12;
        array[1] = 13;
        array[2] = 14;
        array[3] = 15;
        array[4] = 16;
        //获取到下标为0这个元素的值
        System.out.println(array[4]);
        System.out.println(array);//输出的内存址 [I@4554617c

        //创建一个double类型的数组
        double[] d = new double[3];
        d[0] = 12.3;
        d[1] = 12.5;
        d[2] = 23.45;
        System.out.println(d[2]);
        //创建一个String类型的数组
        String[] s1 = new String[3];
        s1[0] = "tom";
        s1[1] = "fender";
        s1[2] = "gibson";
        String name = s1[2];
        System.out.println(name);
    }
}
